﻿<UserControl x:Class="Microsoft.SharepointSnifferPackage.MyControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
             mc:Ignorable="d" 
             d:DesignHeight="480" d:DesignWidth="640"            
             Name="MyToolWindow">

    <UserControl.Resources>

        <XmlDataProvider x:Key="siteinfo"/>

        <HierarchicalDataTemplate x:Key="genTemplate">
            <HierarchicalDataTemplate.ItemsSource>
                <Binding XPath="child::node()"/>
            </HierarchicalDataTemplate.ItemsSource>

            <StackPanel>
                <TextBlock x:Name="tb" Margin="1,0,0,0" Foreground="{Binding XPath=@Color}">
                    <TextBlock.Text>
                        <MultiBinding  StringFormat="{}{0}:{1}">
                            <Binding Path="Name"/>
                            <Binding XPath="@Name"/>
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <TextBlock x:Name="tb2" Margin="1,0,0,0" Foreground="{Binding XPath=@Color}">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}Valor:{0}">
                        <Binding Path="Value"/>
                    </MultiBinding>
                </TextBlock.Text>
                </TextBlock>
            </StackPanel>

            <HierarchicalDataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=Value}" Value="{x:Null}">
                    <Setter TargetName="tb2"  Property="Visibility" Value="Collapsed" />
                </DataTrigger>
                <DataTrigger Binding="{Binding XPath=@Name}" Value="{x:Null}">
                    <Setter TargetName="tb"  Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            </HierarchicalDataTemplate.Triggers>

        </HierarchicalDataTemplate>
    </UserControl.Resources>

    <Grid>
        <DockPanel>
            <DockPanel DockPanel.Dock="Top">
                <Grid>
                    <Button Margin="10,5,0,5" Content="_Start Sniffer" Width="80" Height="25" Name="button1" Click="button1_Click" HorizontalAlignment="Left" />
                    <Button  Margin="110,5,0,5" Content="Open File" Height="25" Name="fopen" Width="80" Click="fopen_Click" HorizontalAlignment="Left"/>
                </Grid>
            </DockPanel>
            <TextBlock Name="T1" DockPanel.Dock="Top"/>
            <TreeView Name ="treeview" ItemTemplate="{StaticResource genTemplate}" DockPanel.Dock="Top" Background="Beige"/>
        </DockPanel>
    </Grid>
</UserControl>
